<%@page import="cn.egame.common.model.PageData"%>
<%@page import="java.util.*"%>
<%@page import="cn.egame.interfaces.gc.TerminalInfo"%>
<%@page import="cn.egame.interfaces.pu.AppParameter"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	PageData pd = new PageData();
	if(request.getAttribute("pd") != null){
		pd = (PageData)request.getAttribute("pd");
	}
	
	List<String[]> brandMap = new ArrayList<String[]>();
	if(request.getAttribute("brandList") != null) {
		brandMap = (List<String[]>)request.getAttribute("brandList");	
	}
	
	List<AppParameter> screenpxList = new ArrayList<AppParameter>();
	if(request.getAttribute("screenpxList") != null) {
		screenpxList = (List<AppParameter>)request.getAttribute("screenpxList");
	}
	
	String shortUa = "";
	if(request.getAttribute("shortUa")!=null) {
		shortUa = (String)request.getAttribute("shortUa");
	}
	
	String uacode = "";
	if(request.getAttribute("uacode")!=null) {
		uacode = (String)request.getAttribute("uacode");
	}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath() %>/css/main.css"  />
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.9.1.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		if(($("#manuId").val()!=0)&&($("#manuId").val()!=-1)) {
			var manu = $("#manuId").val();
			$("#manufacturerid").val(manu);
		}
		
		if(($("#scrPx").val()!=0)&&($("#scrPx").val()!=-1)) {
			var scrp = $("#scrPx").val();
			$("#screenpx").val(scrp);
		}
	});
	
	function search(){
		document.getElementById("myform").action = "<%=request.getContextPath() + "/tv/terminal/list.do" %>";
		document.getElementById("myform").submit();
	}
</script>
<title>机型列表</title>
</head>
<body>
<form action="" id="myform">	
	<div class="matter_box">
		<h3 class="nopoint"><strong>机型列表</strong></h3>
		<% 
			int manuId=0;
			if((request.getAttribute("manuId") != null)&&(Integer.parseInt(request.getAttribute("manuId").toString())!=0)&&(Integer.parseInt(request.getAttribute("manuId").toString())!=-1)) {
				 manuId =  Integer.parseInt(request.getAttribute("manuId").toString());
			}
		%>
		<input id="manuId" type="hidden" value="<%=manuId %>"/>
		<%
			String scrPx = null;
			if((request.getAttribute("scrPx") != null)&&(request.getAttribute("scrPx") != "")) {
				scrPx = (String)request.getAttribute("scrPx");
			}
		%>
		<input id="scrPx" type="hidden" value="<%=scrPx%>"/>
	
		<div class="task_search">
           	<span>品牌</span>
           	<select name="manufacturerid" id="manufacturerid">
          			<option value="0">选择品牌</option>
          			<%  if(brandMap != null){          					
          					for(String[] brand:brandMap) { 
          						if(brand.length==3){
          			%>          					
          					<option value="<%=brand[0] %>"><%=brand[1] %>-<%=brand[2] %></option>
          			<%	
          						}}
	          			}
          			%>
           	</select>
             <span>型号</span>
			<input type="text"  value="<%=shortUa %>" name="shortUa" id="shortUa" maxlength="20" />
             <span>客户端UA特征串</span>
			<input type="text" value="<%=uacode %>" name="uacode" id="uacode" maxlength="30"/>
			<span>分辨率</span>
			<select name="screenpx" id="screenpx">
				<option value="">选择分辨率</option>
				<% 
					if(screenpxList != null){
						for(AppParameter bean:screenpxList){
							%>
							<option value="<%=bean.getName() %>"><%=bean.getName() %></option>
							<%
						}
					}
				%>
           	</select>
        	<span>
        		<input type=button value="查询" onclick="search()" class="upload_btn">
        	</span>
        </div>
		
		
		<p class="tr"><a class="btn2" href="<%=request.getContextPath() + "/tv/terminal/set/show.do" %>">新增机型</a></p>	
		<div class="mt10 pt10 clearfix">
			<table cellpadding="0" cellspacing="0" class="table2">			
			<tr>
				<th>序号</th>
				<th>品牌</th>
				<th>型号</th>
				<th>客户端UA</th>
				<th>分辨率</th>
				<th>操作</th>
			</tr>
	<%
		List<TerminalInfo> list = (List<TerminalInfo>)pd.getContent();
		if(list != null){
			int i = 1;
			for(TerminalInfo bean: list){
				%>
					<tr>
						<td><%=i++ %></td>
						<td><%=bean.getTerminalName() %></td>
						<td><%=bean.getShortUA() %></td>
						<td><%=bean.getUACode() %></td>
						<td><%=bean.getScreenPx() %></td>
						<td>
							<a href="<%=request.getContextPath() + "/tv/terminal/edit.do?terminalId=" + bean.getTerminalId() %>">编辑</a>
							<a href="<%=request.getContextPath() + "/tv/terminal/delete.do?terminalId=" + bean.getTerminalId() %>">删除</a>
						</td>
					</tr>
				<%
			}
		}
		
	%>
	</table>
	<%@ include file="../page.in"  %> 
	</div>
	</div>
</div>
</form>
</body>
</html>